﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Web;

namespace Designit.Umb.Newsletter.Bll
{
    public class Helper
    {

        /// <summary>
        /// Returns a sorted array of list items. All the time zones about which information is available on the local system.
        /// </summary>
        /// <param name="selectedTimezoneId">The selected timezone id.</param>
        /// <returns></returns>
        public static ListItem[] GetTimezoneListItems(string selectedTimezoneId)
        {
            var ret = new ListItem[TimeZoneInfo.GetSystemTimeZones().Count];
            var i = 0;
            foreach (var timeZoneInfo in TimeZoneInfo.GetSystemTimeZones())
            {
                var li = new ListItem(timeZoneInfo.DisplayName, timeZoneInfo.Id);
                if (timeZoneInfo.Id == selectedTimezoneId)
                    li.Selected = true;
                ret[i] = li;
                i++;
            }
            return ret;
        }

        public static string GetTemplateDir()
        {
            var path = "/designit/newsletter/masterpages";
            path = HttpContext.Current.Server.MapPath(path);
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            return path;
        }
    }
}
